<?php

use console\db\Migration;

/**
 * 创建树形结构节点遍历存储过程
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class m190104_091352_p_traverse_node extends Migration {

    /**
     * @var string 存储过程名称
     */
    public $procedureName = 'traversingNode';

    /**
     * @inheritdoc
     */
    public function safeUp() {
        $sql = $this->getData($this->procedureName . '.sql');

        /**
         * @procedure `traversingNode`.
         */
        $this->procedureBuilder([
            'name' => $this->procedureName,
            'params' => [
                [
                    'mode' => 'IN',
                    'name' => 'pk',
                    'type' => 'int',
                    'size' => 11,
                ],
                [
                    'mode' => 'IN',
                    'name' => 'tname',
                    'type' => 'char',
                    'size' => 100,
                ],
                [
                    'mode' => 'OUT',
                    'name' => 'nodes',
                    'type' => 'char',
                    'size' => 255,
                ],
            ],
            'sql' => $sql
        ]);
    }

    /**
     * @inheritdoc
     */
    public function safeDown() {
        $this->dropProcedure($this->procedureName);
    }

}
